#!/bin/bash
while :
do
read -s -p "1 选歌   2 退出" option
echo
echo "$option"
case "$option" in
1)
singer=(`cat 1.txt`)
song=(`cat 2.txt`)
numbersi=`echo ${#singer[@]}`
numberso=`echo ${#song[@]}`
read -s -p "welcome to 'i am a singer' there are ${#singer[@]} singer, enter anykey to continue:" who_care
echo
clear
if  (( ${#singer[@]} == 1 ))
then
        echo -e  "\e[5m\e[31m没得选了就是*** ${singer[@]} ***了压轴的奥\e[0m"
fi
indexsi=`echo $(( RANDOM % numbersi ))`
indexso=`echo $(( RANDOM % numberso ))`
si=`echo ${singer[$indexsi]}`
so=`echo ${song[$indexso]}`
unset singer[$indexsi] 
echo ${singer[@]} >1.txt
unset song[$indexso]
echo ${song[@]} >2.txt
echo -e  "\e[33m $si \e[0m sing the song \e[31m $so \e[0m"
echo "还有 ${#singer[@]} 位歌手" 
echo " there are : ${singer[@]}"
echo -e "\e[31m还有 ${#song[@]} 首歌 \n there are : ${song[@]}\e[0m"
nm=`echo ${#singer[@]}`
ns=`echo ${#song[@]}`
if (( $nm == 1 ))
then 
	echo -e  "\e[8m就剩一个了，大结局啊！！\e[0m"
elif	(( $nm == 0  ))
then
	echo -e "\e[34m歌手将会重新开始\e[0m"
	cat singer.txt  >1.txt
fi
if (( $ns == 0 ))
then
	echo -e  "\e[37m歌曲将会重新开始\e[0m"
	cat song.txt >2.txt
fi
continue
;;
2)
exit
;;
*)
echo "输入错误"
continue
;;
esac

done






